package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.PtfInterfaceModel;
import com.ruoyi.system.service.IPtfInterfaceModelService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;

/**
 * 模型管理Controller
 * 
 * @author ruoyi
 * @date 2022-11-20
 */
@RestController
@RequestMapping("/interfaceModel")
public class PtfInterfaceModelController extends BaseController
{
    @Autowired
    private IPtfInterfaceModelService ptfInterfaceModelService;

    /**
     * 查询模型管理列表
     */
    @RequiresPermissions("system:interfaceModel:list")
    @GetMapping("/list")
    public AjaxResult list(PtfInterfaceModel ptfInterfaceModel)
    {
        List<PtfInterfaceModel> list = ptfInterfaceModelService.selectPtfInterfaceModelList(ptfInterfaceModel);
        return AjaxResult.success(list);
    }

    /**
     * 导出模型管理列表
     */
    @RequiresPermissions("system:interfaceModel:export")
    @Log(title = "模型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PtfInterfaceModel ptfInterfaceModel)
    {
        List<PtfInterfaceModel> list = ptfInterfaceModelService.selectPtfInterfaceModelList(ptfInterfaceModel);
        ExcelUtil<PtfInterfaceModel> util = new ExcelUtil<PtfInterfaceModel>(PtfInterfaceModel.class);
        util.exportExcel(response, list, "模型管理数据");
    }

    /**
     * 获取模型管理详细信息
     */
    @RequiresPermissions("system:interfaceModel:query")
    @GetMapping(value = "/{modelId}")
    public AjaxResult getInfo(@PathVariable("modelId") Long modelId)
    {
        return AjaxResult.success(ptfInterfaceModelService.selectPtfInterfaceModelByModelId(modelId));
    }

    /**
     * 新增模型管理
     */
    @RequiresPermissions("system:interfaceModel:add")
    @Log(title = "模型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtfInterfaceModel ptfInterfaceModel)
    {
        return toAjax(ptfInterfaceModelService.insertPtfInterfaceModel(ptfInterfaceModel));
    }

    /**
     * 修改模型管理
     */
    @RequiresPermissions("system:interfaceModel:edit")
    @Log(title = "模型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtfInterfaceModel ptfInterfaceModel)
    {
        return toAjax(ptfInterfaceModelService.updatePtfInterfaceModel(ptfInterfaceModel));
    }

    /**
     * 删除模型管理
     */
    @RequiresPermissions("system:interfaceModel:remove")
    @Log(title = "模型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modelIds}")
    public AjaxResult remove(@PathVariable Long[] modelIds)
    {
        return toAjax(ptfInterfaceModelService.deletePtfInterfaceModelByModelIds(modelIds));
    }
}
